<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  * {
    padding: 0;
    margin: 0;
  }

  body {
    background: #222;
  }

  .box,
  .stars {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
  }

  .stars {
    background-image: radial-gradient(2px 2px at 50px 200px, #eee, rgba(0, 0, 0, 0)), radial-gradient(2px 2px at 40px 70px, #fff, rgba(0, 0, 0, 0)), radial-gradient(3px 4px at 120px 40px, #ddd, rgba(0, 0, 0, 0));
    background-repeat: repeat;
    background-size: 250px 250px;
    opacity: 0;
    animation: zoom 10s infinite;
  }

  .stars:nth-child(1) {
    background-position: 10% 90%;
    animation-delay: 0s;
  }

  .stars:nth-child(2) {
    background-position: 20% 50%;
    background-size: 270px 500px;
    animation-delay: 0.3s;
  }

  .stars:nth-child(3) {
    background-position: 40% -80%;
    animation-delay: 1.2s;
  }

  .stars:nth-child(4) {
    background-position: -20% -30%;
    transform: rotate(60deg);
    animation-delay: 2.5s;
  }

  .stars:nth-child(5) {
    background-image: radial-gradient(2px 2px at 10px 100px, #eee, rgba(0, 0, 0, 0)), radial-gradient(2px 2px at 20px 10px, #fff, rgba(0, 0, 0, 0)), radial-gradient(3px 4px at 150px 40px, #ddd, rgba(0, 0, 0, 0));
    background-position: 80% 30%;
    animation-delay: 4s;
  }

  .stars:nth-child(6) {
    background-position: 50% 20%;
    animation-delay: 6s;
  }

  @keyframes zoom {
    0% {
      opacity: 0;
      transform: scale(0.5);
      transform: rotate(5deg);
      animation-timing-function: ease-in;
    }

    85% {
      opacity: 1;
    }

    100% {
      opacity: 0.2;
      transform: scale(2.2);
    }
  }

  /* prefers-reduced-motion 用于检测用户的系统是否被开启了动画减弱功能：https://developer.mozilla.org/zh-CN/docs/Web/CSS/@media/prefers-reduced-motion */
  @media (prefers-reduced-motion) {
    .stars {
      animation: none;
    }
  }
</style>

<body>
  <div class="box">
    <div class="stars"></div>
    <div class="stars"></div>
    <div class="stars"></div>
    <div class="stars"></div>
    <div class="stars"></div>
    <div class="stars"></div>
  </div>
</body>

</html>